package Command;

import java.sql.ResultSet;
import java.sql.SQLException;

import Connexion.mysqlConnector;
import Graphique.CompositeCenter;
import Graphique.ExpandedSearch;

public class CommandSave extends Command {

	private ResultSet rs;

	public CommandSave() {
	}

	@Override
	public void execute() {

//		if (!compositeCenter.getFilm().isEmpty()) {
//
//			connector.connection();
//			String film = compositeCenter.getFilm().replaceAll("'", "''");
//			String requete = "Select nameFilm from Film where nameFilm='"
//					+ film + "'";
//			rs = connector.requeteSelect(requete);
//			compositeCenter.getSynopsisArea().setText(compositeCenter.getSynopsisArea().getText().replaceAll("'", "''"));
//			
//
//			try {
//				if (rs == null || !rs.next()) {
//					requete = "Insert into Film(`nameFilm`, `note`, `Synopsis`, `year`, `genre`) values"
//							+ "('"
//							+ film.trim()
//							+ "', "
//							+ (compositeCenter.getComboNote()
//									.getSelectionIndex() + 1)
//							+ ",'"
//							+ compositeCenter.getSynopsisArea().getText()
//							+ "',"
//							+ (compositeCenter.getComboYear()
//											.getSelectionIndex())
//							+ ",'"
//							+ (compositeCenter.getComboGenre()
//									.getSelectionIndex()) + "')";
//
//					if (connector.requete(requete) == 1) {
//						this.listeFilms.add(compositeCenter.getFilm().trim());
//					}
//				}
//
//				else {
//					requete = "update Film set nameFilm ='"
//							+ film.trim()
//							+ "'"
//							+ ",note ="
//							+ (compositeCenter.getComboNote()
//									.getSelectionIndex() + 1)
//							+ ",Synopsis='"
//							+ compositeCenter.getSynopsisArea().getText()
//							+ "'"
//							+ ",year ="
//							+ (compositeCenter.getComboYear()
//									.getSelectionIndex())
//							+ ",genre ="
//							+ (compositeCenter.getComboGenre()
//									.getSelectionIndex())
//							+ " where nameFilm='"
//							+ film.trim() + "'";
//					connector.requete(requete);
//				}
//				connector.closeConnection();
//			} catch (SQLException e) {
//				// TODO Auto-generated catch block
//				e.printStackTrace();
//			}
//		}
//	}
	}

}
